package com.zhongyu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyu.pojo.Panyingpankui;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface PKYKMapper extends BaseMapper<Panyingpankui> {

    @Select(" \n" +
            " SELECT t1.*,t2.name,t3.sname ,t4.username\n" +
            " FROM smbms_panyingpankui t1 \n" +
            " JOIN smbms_goods t2 ON t1.goods_id=t2.id \n" +
            " JOIN smbms_store t3 ON t1.store_id=t3.id\n" +
            " JOIN smbms_user t4 ON t1.creater=t4.id  ${ew.customSqlSegment}\n" +
            " ")
    @ResultMap("providerRm")
    List<Panyingpankui> findAll(Page page, @Param("ew") Wrapper wrapper);

    @Select(" \n" +
            " SELECT t1.*,t2.name,t3.sname ,t4.username\n" +
            " FROM smbms_panyingpankui t1 \n" +
            " JOIN smbms_goods t2 ON t1.goods_id=t2.id \n" +
            " JOIN smbms_store t3 ON t1.store_id=t3.id\n" +
            " JOIN smbms_user t4 ON t1.creater=t4.id WHERE state=0 ${ew.customSqlSegment}")
    @ResultMap("providerRm")
    List<Panyingpankui> find(Page page, @Param("ew") Wrapper wrapper);


    @Select("  SELECT t1.*,t2.name,t3.sname ,t4.username\n" +
            " FROM smbms_panyingpankui t1 \n" +
            " JOIN smbms_goods t2 ON t1.goods_id=t2.id \n" +
            " JOIN smbms_store t3 ON t1.store_id=t3.id\n" +
            " JOIN smbms_user t4 ON t1.creater=t4.id WHERE state=0  AND t1.id=#{id}")
    @ResultMap("providerRm")
    Panyingpankui  searchAll(@Param("id") Integer id);

    @Select("UPDATE smbms_panyingpankui SET state=#{state} ,checktime=#{checktime},checker=#{checker} where id=#{id}")
    void update(@Param("state") Integer state, @Param("checktime") LocalDateTime checktime, @Param("id") Integer id, @Param("checker") Integer shenhe, Panyingpankui panyingpankui);
@Select("UPDATE smbms_panyingpankui SET checktime=#{checktime} ,checker=#{checker},state=#{state} WHERE id=#{id}")
           void updateState(@Param("state") Integer state,@Param("checker") Integer checker, @Param("checktime") LocalDateTime checktime,@Param("id") Integer id);
}
